package com.yznote.compileserver.yCompile.runtime;


import org.springframework.stereotype.Component;

import java.io.File;
import java.util.Map;

@Component
public class CmdExecutor {
    public Process execute(Runtime runtime,String dir, CmdLib cmd,String target, Map.Entry<CmdParam,String>... params) throws Exception{
        // 组装命令
        String cmdVal = cmd.getCommand();
        String param = "";
        for(int i=0;i<params.length;i++){
            param += params[i].getKey().getName()+" "+params[i].getValue()+" ";
        }
        String tCmd = cmdVal+" "+param+" "+target;
        return  runtime.exec(tCmd,null,new File(dir));
    }
}
